package com.magenta.maxoptra.gis;

import com.magenta.maxoptra.dto.GeoLocationRecord;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * User: KuznetsovD
 * Date: 28.06.2010
 * Time: 11:49:11
 */
public interface SyncGeoRoutingService extends ISyncGeoRoutingService {
    public static final String JNDI_NAME = "SyncGeoRoutingService";

    GeoRoute getFastestRoute(GeoProviderSettings settings, GeographicCoordinates from, GeographicCoordinates to);

    List<GeoLocationRecord> getRoutePoints(GeoProviderSettings settings, GeographicCoordinates from,
                                           GeographicCoordinates to, boolean calculateDistance) throws GeoException;

    GeoProviderStatus updateCache(GeoProviderSettings settings, RoutingCoordinate from, RoutingCoordinate to, int delayBeforeRequests);

    /**
     * Bath updating for routes from origin to destination
     *
     * @param settings            geo provider settings
     * @param origin              starting point of the routes
     * @param destinations        list of final destinations
     * @param delayBeforeRequests time that you need to wait before using the provider
     * @return current status of provider
     */
    @Deprecated
    GeoProviderStatus updateCache(GeoProviderSettings settings, GeographicCoordinates origin,
                                  List<? extends GeographicCoordinates> destinations, int delayBeforeRequests);

    GeoRoute getRoute(GeoProviderSettings settings, List<GeographicCoordinates> coordinates) throws GeoException;

    List<GeoLocationRecord> getRoutePoints(GeoProviderSettings settings, List<GeographicCoordinates> points) throws GeoException;

    /**
     * Bath updating for routes between points
     *
     * @param from                starting point of the routes
     * @param settings            geo provider settings
     * @param points              points of the routes
     */
    void updateCache(GeoProviderSettings settings, RoutingCoordinate from, List<RoutingCoordinate> points);

    /**
     * Batch updating for routes between points (w/o reverse routes)
     */
    void updateCache(GeoProviderSettings settings, List<RoutingCoordinate> from, List<RoutingCoordinate> to);

    /**
     * Clean expired cache and return date of first oldest entry
     *
     * @param maxAge milliseconds
     * @return date of first oldest entry
     */
    long cleanAndGetDateOfFirstOldest(long cid, long maxAge);

    /**
     * Getting distance and trip duration going through all points in order in which they are listed
     *
     * @param settings    geo provider settings
     * @param coordinates list of stops
     * @return calculated distance and duration
     */
    @Nullable
    List<GeoRoute> getCoordinateToCoordinateRoutes(GeoProviderSettings settings, List<GeographicCoordinates> coordinates);
}
